function bbcode(debut, fin)
{
        var input = window.document.form.texte;
        input.focus();
 
        if(typeof document.selection != 'undefined')
        {
                var range = document.selection.createRange();
                var insText = range.text;
                range.text = debut + insText + fin;
                range = document.selection.createRange();
                if (insText.length == 0)
                {
                        range.move('character', -fin.length);
                }
                else
                {
                        range.moveStart('character', debut.length + insText.length + fin.length);
                }
                range.select();
        }
 
        else if(typeof input.selectionStart != 'undefined')
        {
                var start = input.selectionStart;
                var end = input.selectionEnd;
                var insText = input.value.substring(start, end);
                input.value = input.value.substr(0, start) + debut + insText + fin + input.value.substr(end);
                var pos;
                if (insText.length == 0)
                {
                        pos = start + debut.length;
                }
                else
                {
                        pos = start + debut.length + insText.length + fin.length;
                }
                input.selectionStart = pos;
                input.selectionEnd = pos;
        }
        else
        {
                var pos;
                var re = new RegExp('^[0-9]{0,3}$');
                while(!re.test(pos))
                {
                        pos = prompt("insertion (0.." + input.value.length + "):", "0");
                }
                if(pos > input.value.length)
                {
                        pos = input.value.length;
                }
                var insText = prompt("Veuillez taper le texte");
                input.value = input.value.substr(0, pos) + debut + insText + fin + input.value.substr(pos);
        }
}
function smilies(img)
{
        window.document.formulaire.message.value += '' + img + '';
}
function show_lines(lien)
{
	if(!lien.line_showed) lien.line_showed=0;
	lien.line_showed++;
	
	var show=(lien.line_showed%2==0) ? true : false;

	var div_code=lien.parentNode.nextSibling.childNodes[0];
	var key=0;
	var i=1;
	var numberLine=0;
	var start='';
	var line_actu='';
	
	while(key < div_code.childNodes.length)
	{
		if(div_code.childNodes[key].nodeName.toLowerCase() == 'span' && div_code.childNodes[key].className=='count')
			numberLine++;
		key++;
	}
	
	key=0;
	numberLine=''+numberLine;
	while (key < div_code.childNodes.length)
	{
		if(div_code.childNodes[key].nodeName.toLowerCase() == 'span' && div_code.childNodes[key].className=='count')
		{
			if(show==false)
			{
				div_code.childNodes[key].style.display='none';
				div_code.childNodes[key].innerHTML='';
			}
			else
			{
				start='';
				line_actu=''+i;
				for(var j=0;j<(numberLine.length-line_actu.length);j++)
					start+='&nbsp;';
				div_code.childNodes[key].style.display='inline';
				div_code.childNodes[key].innerHTML=start+i+' ';
				i++;
			}
		}
		key++;
	}
	return false;
}

